var express = require('express');

var app = express();
var apis = require('./apis.js')

var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

app.all('*', function(req, res, next) {
　　//设置允许跨域的域名，*代表允许任意域名跨域
    res.header("Access-Control-Allow-Origin", "*");
　　//允许的header类型
    res.header('Access-Control-Allow-Headers', 'Content-Type,Origin,csrf,year, Content-Length, Authorization,xxl_sso_sessionid, Accept, X-Requested-With , If-None-Match,Referer,User-Agent');
　　//跨域允许的请求方式
    res.header("Access-Control-Allow-Methods", "POST,GET");
　　//可选，用来指定本次预检请求的有效期，单位为秒。在此期间，不用发出另一条预检请求。
    res.header('Access-Control-Max-Age',1728000);//预请求缓存20天
	res.header('Content-Type', 'application/json;charset=utf-8')

    next(); 
	
	
});


app.use('/api', apis);
app.use(function(err, req, res, next) {
		console.log(req)
	next();
});
module.exports = app

